package com.sishu.njrtsdms.enums;

import com.sishu.njrtsdms.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.jooq.types.ULong;


@Getter
@AllArgsConstructor
@Slf4j
public enum DictDataEnum {

    // ----------Sex Enum---------------

    /**
     * 男
     */
    MALE(ULong.valueOf(1), "1", "男"),

    /**
     * 女
     */
    FEMALE(ULong.valueOf(1), "2", "女"),

    /**
     * 未知
     */
    UNKNOWN(ULong.valueOf(1), "3", "未知"),

    // ----------Project audit status enum---------------

    /**
     * 待申报
     */
    TO_BE_DECLARED(ULong.valueOf(6), "1", "待申报"),
    /**
     * 退回
     */
    SEND_BACK(ULong.valueOf(6), "2", "退回"),
    /**
     * 部门审核中
     */
    DEPT_AUDITING(ULong.valueOf(6), "3", "部门审核中"),
    /**
     * 管理员审核中
     */
    ADMIN_AUDITING(ULong.valueOf(6), "4", "管理员审核中"),
    /**
     * 审核通过
     */
    AUDIT_APPROVED(ULong.valueOf(6), "5", "审核通过"),
    /**
     * 审核不通过
     */
    AUDIT_FAILED(ULong.valueOf(6), "6", "审核不通过"),

    // ----------Project audit level enum---------------

    /**
     * 部门审核
     */
    DEPT_AUDIT_LEVEL(ULong.valueOf(7), "1","部门审核"),

    /**
     * 管理员审核
     */
    ADMIN_AUDIT_LEVEL(ULong.valueOf(7), "2","管理员审核"),

    // ----------Project audit operation enum---------------

    /**
     * 审核通过操作
     */
    AUDIT_PASS_OP(ULong.valueOf(8), "1","审核通过"),
    /**
     * 审核退回操作
     */
    SEND_BACK_OP(ULong.valueOf(8), "2","审核退回"),
    /**
     * 审核终止操作
     */
    TERMINATE_OP(ULong.valueOf(8), "3","审核终止"),

    // ----------user type enum---------------
    ADMIN(ULong.valueOf(9), "1","管理员"),

    DEAN(ULong.valueOf(9), "2","院长"),

    TEACHER(ULong.valueOf(9), "3","教师"),

    // ----------user status enum---------------
    NORMAL(ULong.valueOf(10), "1","正常"),

    DISABLED(ULong.valueOf(10), "2","禁用"),

    // ----------user login status enum---------------

    LOGIN_SUCCESS(ULong.valueOf(11), "1","登陆成功"),

    LOGIN_FAIL(ULong.valueOf(11), "2","登陆失败");


    /**
     * 字典类型id
     */
    private final ULong dictTypeId;

    /**
     * 字典数据值
     */
    private final String dictDataValue;

    /**
     * 字典数据标签
     */
    private final String dictDataLabel;


    public static DictDataEnum getEnumByDictTypeIdAndValue(ULong dictTypeId,
                                                           String dictDataValue) {
        for (DictDataEnum dictDataEnum : DictDataEnum.values()) {
            if (dictDataEnum.dictTypeId.equals(dictTypeId)
                    && dictDataEnum.dictDataValue.equals(dictDataValue)) {
                return dictDataEnum;
            }
        }
        log.error("不存在的字典数据枚举,字典类型id:{},字典数据值:{}", dictTypeId, dictDataValue);
        throw new ServiceException("系统内部异常");
    }


}
